]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
[lg] Close inspector on Esc
authorDan Winship <danw@gnome.org>
Wed, 21 Jul 2010 15:37:08 +0000 (11:37 -0400)
committerDan Winship <danw@gnome.org>
Mon, 23 Aug 2010 17:03:58 +0000 (13:03 -0400)
https://bugzilla.gnome.org/show_bug.cgi?id=624940

js/ui/lookingGlass.js

index 7f6f4c112c715ee08f75f3788c5dd92b903d6561..5c350d1c9293877ea57985ebb1cd8b8af9ec8fcf 100644 (file)
@@ -382,10 +382,12 @@ Inspector.prototype = {
         this._borderPaintTarget = null;
         this._borderPaintId = null;
         eventHandler.connect('destroy', Lang.bind(this, this._onDestroy));
+        eventHandler.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
         eventHandler.connect('button-press-event', Lang.bind(this, this._onButtonPressEvent));
         eventHandler.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
         eventHandler.connect('motion-event', Lang.bind(this, this._onMotionEvent));
         Clutter.grab_pointer(eventHandler);
+        Clutter.grab_keyboard(eventHandler);
 
         // this._target is the actor currently shown by the inspector.
         // this._pointerTarget is the actor directly under the pointer.
@@ -398,6 +400,7 @@ Inspector.prototype = {
 
     _close: function() {
         Clutter.ungrab_pointer(this._eventHandler);
+        Clutter.ungrab_keyboard(this._eventHandler);
         this._eventHandler.destroy();
         this.emit('closed');
     },
@@ -407,6 +410,12 @@ Inspector.prototype = {
             this._borderPaintTarget.disconnect(this._borderPaintId);
     },
 
+    _onKeyPressEvent: function (actor, event) {
+        if (event.get_key_symbol() == Clutter.Escape)
+            this._close();
+        return true;
+    },
+
     _onButtonPressEvent: function (actor, event) {
         if (this._target) {
             let [stageX, stageY] = event.get_coords();